package ai.fabu.dataplatform.utils;

import ai.fabu.dataplatform.help.Result;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.*;

import static ai.fabu.dataplatform.constant.ConstantValue.THREAD_POOL_NUMBER;

public class ThreadManager {
    private final static int threadPoolNumber = THREAD_POOL_NUMBER;
    private final static ExecutorService executorService = Executors.newFixedThreadPool(threadPoolNumber);
    public static Future<?> submit(Callable<?> task){
        return executorService.submit(task);
    }

    public static Future<?> submit(Runnable task){
        return executorService.submit(task);
    }

    public static List<Future<Result>> invokeAll(Collection<Callable<Result>> tasks) throws InterruptedException {
        return executorService.invokeAll(tasks);
    }

}
